<?php
#=========================================================================================
#	Filename: getStatsClass.php
#	Note	: stats Class
#	Version : 1.0
#	Author  : Peter
#	Update  : 2010-04-23
#======================================================================================== 
class getStatsClass{
	//instance var
	private static $instance = NULL;
	
	//construct function
	private function __construct(){
		
	}
	
	//clone function 
	private function __clone(){
		
	}
	
	public static function getInstance(){
		if(self::$instance == NULL)
			self::$instance = new getStatsClass();
		return self::$instance;
	}
	
	/*
	 * Return All stats
	*/
	public function getStats(){
		$stat_array = statClass::$state;
		
		return array_keys($stat_array);
	}
	
	/*
	 * Return stats Section
	 */
	public function getStatsSection(){
		$stat_array = statClass::$state;
		$return_array = array();
		foreach($stat_array as $kk => $vv){
			foreach($vv  as $sectionKey => $sectionValue)
				$return_array[] = ucwords(strtolower($sectionKey));
		}
		
		return $return_array;
	}
	
	/*
	 * Return Country Name
	 * 
	 */
	public function getCountryName(){
		$stat_array = statClass::$state;
		$return_array = array();
		foreach($stat_array as $kk => $vv){
			foreach($vv  as $sectionKey => $sectionValue)
				$return_array[] = $sectionValue;
		}
		print_r($_SERVER);
		//return $return_array;
	}
	public function getRegion($region){
		$stat_array = statClass::$state;
		return isset($stat_array[$region]) ? ($stat_array[$region]) : array();
	}
	public function getSubByRegion($region){
		$stat_array = statClass::$state;
		return isset($stat_array[$region]) ? array_keys($stat_array[$region]) : array();
	}
	public function getCountrysByRegionAndSub($region, $sub){
		$stat_array = statClass::$state;
		return isset($stat_array[$region][$sub]) ? $stat_array[$region][$sub] : array();
	}
	public function getCountryByAll($region, $sub, $code){
		$stat_array = statClass::$state;
		return isset($stat_array[$region][$sub][$code]) ? $stat_array[$region][$sub][$code] : '';
	}
	public function getStatsFromXML(){
		$xmlPath = 'inc/countryCode.xml';
		$regions = parseCountryCode::parseXml($xmlPath);
		return array_keys($regions);
	}
}
?>